<?php
if(!defined('ADMINPX') || !defined('ADMIN')) {
	exit('Access Denied');
}
$act=$_GET['act'];
$id=$_GET['id'];
$adminid=$_GET['adminid'];
if($act =='ok'){
	       $name=$_POST['name'];
	       $xixis=$_POST['xixis'];
	       $name_ys=$_POST['name_ys'];
	       $jifena=$_POST['jifena'];
	       $qxid=$_POST['qxid'];
	       $sezi_forum_fat=$_POST['sezi_forum_fat'];
         if($_POST['delete']){
            foreach($_POST['delete'] as $val ){
                $db->delete('user_qxz'," `id` = '$val'");
            }
         }
         foreach($_POST['name'] as $a => $val ){
    	  	      $db->update('user_qxz',array('name' => $val ,'xixis' => $xixis[$a],'name_ys' => $name_ys[$a],'jifen' => $jifena[$a],'sezi_forum_fat' => $sezi_forum_fat[$a] )," `id`= '$a'");
                if($db->get_one('user_qxz',"`type` ='1' and `type_a` ='0' and `id`= '$a' ",'')){
    	  	         $db->update('user_qxz',array('qxid' => $qxid[$a] )," `id`= '$a'");
    	  	      }
         }
         if($name[0]){
         	      if($_GET['lx'] == 'ok'){
         	    	   if($jifena[0] > '0' && !$db->get_one('user_qxz'," `jifen` = '$jifena[0]' " ,'')){
         	    	   	  $db->insert('user_qxz',array('id' => 'NULL','type' => '0','type_a' => '0','qxid' => '0','xixis' => '0','name' => $name[0],'name_ys' =>'' ,'jifen' => $jifena[0]));
         	    	   }
                }else{
         	    	      $db->insert('user_qxz',array('id' => 'NULL','type' => '1','type_a' => '0','qxid' => $qxid[0],'xixis' => '0','name' => $name[0],'name_ys' =>'' ));
                }
         }
	       echo "编辑成功<br/>";	
         echo "正在自动返回.......<br/><a href=\"admin.php?action=user_jifenqx\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=user_jifenqx&'>";
}else{
echo <<<end
<div class="admin">用户组<br/></div>
<form method="POST" action="admin.php?action=user_jifenqx&act=ok" >
end;
	 $sql=$db->query('user_qxz',"`type` = '1' ORDER BY `id` ","");
	 while($row=mysql_fetch_array($sql)){
	 	if($row[type_a] == '1'){
	 		 $namep='disabled="disabled"';
	 	   if($row[qxid] == '10'){$nameqx='系统员';}elseif($row[qxid] == '8'){$nameqx='管理员';}elseif($row[qxid] == '6'){$nameqx='坛主管';}elseif($row[qxid] == '5'){$nameqx='版主';}elseif($row[qxid] == '-3'){$nameqx='禁止登陆';}elseif($row[qxid] == '-2'){$nameqx='禁止发表';}elseif($row[qxid] == '-1'){$nameqx='锁定会员';}elseif($row[qxid] == '0'){$nameqx='普通';}
	 	}else{
	 		 $namep='name="delete[]" value="'.$row[id].'"';
	 		 if($row[qxid] == '8'){$namlxa='selected="selected"';}elseif($row[qxid] == '6'){$namlxb='selected="selected"';}elseif($row[qxid] == '5'){$namlxc='selected="selected"';}elseif($row[qxid] == '0'){$namlxd='selected="selected"';}
	 		 $nameqx='<select name="qxid['.$row[id].']"><option value="8" '.$namlxa.'>管理员</option><option value="6" '.$namlxb.'>坛主管</option><option value="5" '.$namlxc.'>版主</option><option value="0" '.$namlxd.'>普通</option></select>';
	 	}
echo <<<end
<div class='admin_a'>
<input class="checkbox" type="checkbox" $namep />
<input type="hidden" name="jifena[$row[id]]" value="0" size=1/>
<input type="hidden" name="sezi_forum_fat[$row[id]]" value="0" size=1/>
组名称<input type="text" name="name[$row[id]]" value="$row[name]" size=5/>
星数<input type="text" name="xixis[$row[id]]" value="$row[xixis]" size=2/>
级别:<b>$nameqx</b>
<font color="$row[name_ys]">颜色</font><input type="text" name="name_ys[$row[id]]" value="$row[name_ys]" size=5/>
</div>
end;
	}
echo <<<end
<div class='admin_a'>
<b>+新增</b>  组名称<input type="text" name="name[0]" value="$row[name]" size=5/>
权限<select name="qxid[0]"><option value="8">管理员</option><option value="6" >坛主管</option><option value="6">版主</option><option value="0" selected="selected">普通</option></select>
</div>
<div class='admin_a'>
<input type="checkbox" name="chkall" id="chkallpqwy" class="checkbox" onclick="checkAll('prefix', this.form, 'delete')" /><b>删除</b>?
<input type="submit" value="提交" name="b1" />
</div>
</form>
<div class="admin">用户头衔<br/></div>
<form method="POST" action="admin.php?action=user_jifenqx&act=ok&lx=ok" >
end;
	 $sql=$db->query('user_qxz',"`type` = '0' ORDER BY `jifen` ","");
	 while($row=mysql_fetch_array($sql)){
	 	     $usersms=$db->get_one('user_qxz'," `jifen` > '$row[jifen]' ORDER BY `jifen` LIMIT 0 , 1",'');
	 	     if(!$usersms[id]){$usersms[jifen]='999999999';}
	 	     if($row[type] == '1'){$namep='disabled="disabled"';}else{$namep='name="delete[]" value="'.$row[id].'"';}
echo <<<end
<div class='admin_a'>
<input class="checkbox" type="checkbox" $namep />
组头衔<input type="text" name="name[$row[id]]" value="$row[name]" size=5/>
星数<input type="text" name="xixis[$row[id]]" value="$row[xixis]" size=1/>
经验<input type="text" name="jifena[$row[id]]" value="$row[jifen]" size=1/> -
<input type="text" name="jifenb[$row[id]]" value="$usersms[jifen]" disabled size="1" />
<font color="$row[name_ys]">颜色</font><input type="text" name="name_ys[$row[id]]" value="$row[name_ys]" size=5/>
<br/>&nbsp;&nbsp;&nbsp;<font color="#FF0000"><b>设置</b></font>
每天发帖<input type="text" name="sezi_forum_fat[$row[id]]" value="$row[sezi_forum_fat]" size=1/>
</div>
end;
	}
echo <<<end
<div class='admin_a'>
<b>+新增</b>  组头衔<input type="text" name="name[0]" value="$row[name]" size=5/>
       积分<input type="text" name="jifena[0]" value="9999" size=1/>
</div>
<div class='admin_a'>
<input type="checkbox" name="chkall" id="chkallpqwy" class="checkbox" onclick="checkAll('prefix', this.form, 'delete')" /><b>删除</b>?
<input type="submit" value="提交" name="b1" />
</div>
</form>
end;



}
?>